package com.imooc.distributedemo.resume.leetcode;

/**
 * leetcode75 颜色分类
 */
public class Solution75 {
    public static void main(String[] args) {
        int[] nums={2,0,2,1,1,0};
        sortColors(nums);
    }

    public static void sortColors(int[] nums) {
        if(null==nums||nums.length<1){
            return;
        }
        int size=nums.length;
        int pt=0;
        for (int i = 0; i < size; ++i) {
            if(nums[i]==0){
                int tmp = nums[i];
                nums[i]=nums[pt];
                nums[pt]=tmp;
                ++pt;
            }
        }

        for (int i = pt; i < size; ++i) {
            if(nums[i]==1){
                int tmp = nums[i];
                nums[i]=nums[pt];
                nums[pt]=tmp;
                ++pt;
            }
        }
    }
}
